package cn.itsource.consumer;
import cn.itsource.config.RabbitMQConfig;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;


@Component
public class MyConsumer {


    @RabbitListener(queues = RabbitMQConfig.SPRINGBOOT_QUEUE1)
    public void getUser(Channel channel,Message message, String msg){
          //一旦有消息这个方法就会被调用
        System.out.println(msg);
        try {
            //签收消息
            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }


    @RabbitListener(queues = RabbitMQConfig.SPRINGBOOT_QUEUE2)
    public void getProduct(Channel channel,String msg){

        System.out.println(msg);

    }





}
